<template>
  <div class="remove-member">
    <el-dialog width="30%" title="删除成员" v-model="dialogVisible" center>
      <el-form :model="form" label-width="auto">
        <el-form-item label="微信号" label-width="auto">
          <el-input v-model="form.wxForm" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="removeRole">确 定</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, reactive } from 'vue'
import { requestRemoveRole } from '@/service/main/main'
import { ElMessageBox } from 'element-plus'
import { ElMessage } from 'element-plus'
export default defineComponent({
  setup() {
    let dialogVisible = ref(false)
    let form = reactive({
      wxForm: '',
    })
    const changeVisibility = (value: boolean) => {
      dialogVisible.value = value
    }
    const open = () => {
      ElMessageBox.confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          requestRemoveRole(form.wxForm, 2)
          dialogVisible.value = false
          ElMessage({
            type: 'success',
            message: '删除成功!',
          })
        })
        .catch(() => {
          ElMessage({
            type: 'info',
            message: '已取消删除',
          })
        })
    }
    const removeRole = () => {
      open()
    }

    return { dialogVisible, changeVisibility, form, removeRole }
  },
})
</script>

<style scoped></style>
